//
//  OAAttendanceTests.m
//  OANetworkManager_Tests
//
//  Created by TFAppleWork-Summer on 2018/2/27.
//  Copyright © 2018年 GuoRui. All rights reserved.
//

#import "Tests.h"
#import "AppNetworkingManager+OAAttendance.h"
#import "OAExceptionReprotCommitModel.h"
#import "OAUserModel.h"
@interface OAAttendanceTests : Tests

@end

@implementation OAAttendanceTests

- (void)setUp {
    [super setUp];
    // Put setup code here. This method is called before the invocation of each test method in the class.
}

- (void)tearDown {
    // Put teardown code here. This method is called after the invocation of each test method in the class.
    [super tearDown];
}

- (void)testExample {
    // This is an example of a functional test case.
    // Use XCTAssert and related functions to verify your tests produce the correct results.
}
//测试考勤记录
-(void)testGetDateInfo{
    
    [self expectation:^(void (^fulfill)(void)) {
        NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
        [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
        NSString *dateStr = @"2018-02-21 08:00:00";
        NSDate *date = [formatter dateFromString:dateStr];
        long long dateTime  = [date timeIntervalSince1970] * 1000;

        [AppNetworkingManager getAttendanceDateInfoWithDate:dateTime complete:^(NSArray *exceptionRecordArray, OAAttendanceRecordModel *attendanceRecordModel, NSError *error) {
            
            NSLog(@"array : %@",exceptionRecordArray);
            NSLog(@"model: %@",attendanceRecordModel);
            fulfill();
        }];
        
    }];
}

-(void)testExpt{
    [self expectation:^(void (^fulfill)(void)) {
        NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
        [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
        NSString *dateStr = @"2018-04-01 08:00:00";
        NSDate *date = [formatter dateFromString:dateStr];
        long long dateTime  = [date timeIntervalSince1970] * 1000;
        
        [AppNetworkingManager getExpSignWithDate:dateTime complete:^(id object, NSError *error) {
             fulfill();
        }];
    }];
}

-(void)testAddOrUpload{
    [self expectation:^(void (^fulfill)(void)) {
    
        NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
        [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
        NSString *dateStr = @"2018-02-27 14:00:00";
        NSDate *date = [formatter dateFromString:dateStr];
        long long dateTime  = [date timeIntervalSince1970] * 1000;
        [AppNetworkingManager getAttendanceDateInfoWithDate:dateTime complete:^(NSArray *exceptionRecordArray, OAAttendanceRecordModel *attendanceRecordModel, NSError *error) {
            
//            OAExceptionReprotCommitModel *commitModel = exceptionRecordArray[0];
//            commitModel.explain = @"吴刚非要我写一个事由";
            //创建一个抄送人
//            OAUserModel *useModel = [[OAUserModel alloc]init];
//            useModel.userId = @"163";
//            useModel.userName = @"郭睿";
//            commitModel.ccs = @[useModel];
//            commitModel.approvers = @[useModel];

            OAExceptionReprotCommitModel *commitModel = [[OAExceptionReprotCommitModel alloc]init];
            commitModel.isMaintain=2;
            commitModel.time=1520301600000;
            commitModel.explain=@"阿爸";
            commitModel.type=102;
            commitModel.approveStatus=0;
            commitModel.reason=@"上班没打卡";
            OAUserModel *userModel = [[OAUserModel alloc]init];
            userModel.position = @"iOS开发工程师";
            userModel.login = false;
            userModel.avatorImageURLString = @"http://testoa.v5time.net/oaMobile/img/avatar/usr.jpg";
            userModel.departmentId = @"24";
            userModel.userName = @"汪陈陈";
            userModel.userId=@"214";
            userModel.userDesc = @"我是张杰";
            userModel.orederIndex=0;
            
            commitModel.reporter = userModel;
            commitModel.reportId=@"4733";
            commitModel.reportType=100;
            commitModel.ccs=@[];
            commitModel.rejectReason = @"";
            
            NSArray *images = @[[UIImage imageNamed:@"big"] , [UIImage imageNamed:@"big"],[UIImage imageNamed:@"big"]];
            [AppNetworkingManager addOrUpdateWithString:commitModel
                                               images:images
                                               complete:^(id object, NSError *error) {
                                                  
                fulfill();
            }];
        }];
    }];
}



- (void)testPerformanceExample {
    // This is an example of a performance test case.
    [self measureBlock:^{
        // Put the code you want to measure the time of here.
    }];
}

@end
